package com.lz.comm.widget.camera

import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatRadioButton

/**
 * Created by you on 2018-03-27.
 */
class ToggleRadioButton : AppCompatRadioButton {

    var listener: OnUnToggleListener? = null

    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)

    override fun toggle() {
        if (!isChecked) {
            super.toggle()
        } else {
            listener?.onUnToggle(this)
        }
    }

    /**
     * 已经选中时的点击响应
     */
    interface OnUnToggleListener {

        fun onUnToggle(button: ToggleRadioButton)
    }
}